﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

namespace NDaisy.Core.Utility
{
    public static class Typefinder
    {
        public static IEnumerable<Type> GetTypeEndWith(string endwith, params string[] assemblyNames)
        {
            var types = new List<Type>();
            foreach (var assemblyName in assemblyNames)
            {
                var startUpTaskTypes = Assembly.Load(new AssemblyName(assemblyName))
            .DefinedTypes.Where(d => d.Name.EndsWith(endwith))
            .Select(d => d.AsType());

                types.AddRange(startUpTaskTypes);
            }
            return types;
        }

    }
}
